package cn.edu.zut.cs.Service;
import cn.edu.zut.cs.DAO.SCDAO;
import cn.edu.zut.cs.Model.SC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;

//加注解来省去new一个Service对象
@Service
public class SCService {
    SCDAO scDAO;
    @Autowired
    public void setScDAO(SCDAO scDAO) {
        this.scDAO = scDAO;
    }

    public void insertSC(SC s){
        //这里省去了DAO工厂的创建
//        SCDAO dao = DaoFactory.getSCDao();
//        System.out.println(dao.toString());
//        dao.insert(b);
        scDAO.insert(s);
    }

    public List<SC> getAll(){
        return scDAO.getAllSCs();
    }
    @Transactional
    public SC search(SC s){
        return scDAO.selectOne(s);
    }

}